'''
Created on Oct 21, 2009

@author: kage
'''

from PyBatch.handlers import base

class AudioReplacer(base.MuxBase):
    def start(self, args=None):
        q='"'
        self.__inputPath = args['inputPath'].replace('\\','/')
        self.__replacementAudioPath = args['replacementAudioPath'].replace('\\','/')
        self.__outputPath = args['outputPath'].replace('\\','/')
        self.__video_track = args['video_track']
        self.__audio_track = args['audio_track']
        self.__title = args['title']
        
        self.__command = q + self.mkvMergePath + q + " -o " + q + self.__outputPath + q
        self.__command += ' "--priority" "' + self.priority + '" "--default-track" "1:yes" "--forced-track" "1:no" ' 
        self.__command += '"--language" "2:eng" "--default-track" "2:yes" "--forced-track" "2:no" '
        self.__command += '"-A" "-d" ' + q + self.__video_track + q + " "
        self.__command += '"-S" ' + q + self.__inputPath + q + ' "--language" "1:eng" "--default-track" "1:yes" "--forced-track" "1:no" "-a" "' + self.__audio_track + '" "-D" "-S" ' 
        self.__command += q + self.__replacementAudioPath + q + ' "--track-order" "0:' + self.__video_track + ',1:' + self.__audio_track + '" "--title" "' + self.__title + '"'
        
        self.setCommandLine(self.__command)
        self.muxOperation()
